package com.Controller;


import com.Service.GameService;
import com.entity.Game;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class GameController {

    @Autowired
    private GameService gameService;

    /**
     * 查询
     * @param game
     * @return
     */
    @RequestMapping(value = "/queryGame",method = RequestMethod.GET)
    public List<Game> queryGame(Game game){
        return gameService.queryGame(game);
    }

    /**
     * 新增
     * @param game
     * @return
     */
    @RequestMapping(value = "/addGame",method = RequestMethod.POST)
    public int addGame(@RequestBody Game game){
        return gameService.addGame(game);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/delGame/{id}",method = RequestMethod.DELETE)
    public int delGame(@PathVariable int id){
        return gameService.delGame(id);
    }

    /**
     * 修改
     * @param game
     * @return
     */
    @RequestMapping(value = "/updateGame/{id}",method = RequestMethod.PUT)
    public int updateGame(@RequestBody Game game,@PathVariable int id){
        game.setGameId(id);
        return gameService.updateGame(game);
    }
}
